<?php

class lineChart extends CWidget {

    public $title;
    public $subtitle;
    public $categories;
    public $yTitle;
    public $valueSuffix;
    public $series;

    public function run() {
        $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets');
        $cs = Yii::app()->getClientScript();
        $cs->registerScriptFile($assets . '/js/highcharts.js', CClientScript::POS_END);
        $this->render('lineChart');
    }

    public function getChartData() {
        foreach ($this->series as $data)
            $series[] = array('name' => (string) $data['name'], 'data' => $data['data']);
        return json_encode($series);
    }

}
